<template>
  <div @click="onToggle" id="guide-full">
    <el-tooltip
      :content="
        isFullscreen
          ? $t('msg.navBar.exitFullscreen')
          : $t('msg.navBar.enterFullscreen')
      "
    >
      <div>
        <svg-icon :icon="isFullscreen ? 'exit-fullscreen' : 'fullscreen'" />
      </div>
    </el-tooltip>
  </div>
</template>

<script setup>
import { ref, onMounted, onUnmounted } from 'vue'
import screenfull from 'screenfull'

// 是否全屏
const isFullscreen = ref(false)

// 切换事件
const onToggle = () => {
  // 点击的时候切换状态
  isFullscreen.value = !isFullscreen.value
  screenfull.toggle()
}
// 老师给的监听的方法，可以了解一下，但是没必要这么麻烦
// 监听变化
// const change = () => {
//   isFullscreen.value = screenfull.isFullscreen
// }
// 设置侦听器
// onMounted(() => {
//   screenfull.on('change', change)
// })

// 删除侦听器
// onUnmounted(() => {
//   screenfull.off('change', change)
// })
</script>

<style lang="scss" scoped></style>
